﻿	
CREATE TABLE [dbo].[CmsMenu]
(
	[ID] [int] primary key NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[UpperID] [int] NOT NULL,
	[Path] [varchar](100) NOT NULL,
	[Depth] [int] NOT NULL,
	[Orders] [int] NULL,
	[Code] [int] not null unique,
	[TypeID] [int] NOT NULL	,
	ArticleSmallImageSize int not null,
	ArticleBigImageSize int not null,
	PicSallImageSize int not null,
	PicBigImageSize int not null,
	PicSaveOrignImage bit not null,
)
insert into [dbo].[CmsMenu] ([ID],[Name],[UpperID],[Depth],[Path],[Orders],Code,TypeID,ArticleSmallImageSize,ArticleBigImageSize,PicSallImageSize,PicBigImageSize,PicSaveOrignImage) values  (1,'根栏目',0,0,',',0,0,0,0,0,0,0,0);



go

create table [dbo].[CmsArticle]
(
	[ID] [int] primary key NOT NULL,
	[Name] [varchar](100) NULL,
	[MenuID] int not null foreign key references CmsMenu(ID)  on delete cascade,
	[MenuName] nvarchar(100),
	[Source] [varchar](500) NULL,
	[CreatorID] [int] NOT NULL,
	[CreatorName] [nvarchar](50) NOT NULL,
	[Summary] [nvarchar](1000) NULL,
	[Content] [nvarchar](max) NULL,
	[InputTime] [datetime] NOT NULL,
	[UpdateTime] [datetime] NOT NULL,
	[KeyWords] [nvarchar](1000) NULL,
	[IsRecommend] [bit] NOT NULL,
	[IsDisplay] [bit] NOT NULL,
	[Orders] [int] NULL,
	[ClickCount] [int] NOT NULL   DEFAULT ((0)),
	SmallImage [varchar](200) NULL,
	BigImage varchar(200)
)
--update cmsarticle set menuid=(select MenuID from cmsmenuarticle where ArticleID=cmsarticle.id)
--update cmsarticle set menuname= (select Name from cmsmenu where ID = menuid)

go

create table [dbo].[CmsMenuArticle]
(
	[MenuID] [int] foreign key references [dbo].[CmsMenu]([ID]) on delete cascade,
	[ArticleID] [int] foreign key references [dbo].[CmsArticle]([ID]) on delete cascade
	primary key ([MenuID],[ArticleID])
	 
) 


create table [dbo].[CmsArticlePicture]
(
	[ID] [int] primary key NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[BindID] [int] foreign key references [dbo].[CmsArticle]([ID]) on delete cascade NOT NULL,
	[Remark] [nvarchar](500) NULL,
	[Flag] [varchar](50) NULL,
	[Size] [int] NOT NULL,
	[Width] [int] NOT NULL,
	[Height] [int] NOT NULL,
	[InputTime] [datetime] NOT NULL,
	SmallImage [varchar](500) NULL,
	BigImage [varchar](500) NULL,
	OriginImage [varchar](500) NULL,
	ClickCount int not null,
	Orders int not null,

)

CREATE TABLE [dbo].[CmsArticleAttach]
(
	[ID] [int] primary key NOT NULL,
	[Name] [varchar](200) NOT NULL,
	[BindID] [int] foreign key references [dbo].[CmsArticle]([ID]) on delete cascade NOT NULL,
	[Path] [varchar](100) not null,
	[Type] [varchar](100) not null,
	[Size] [int] NOT NULL,
	[InputTime] [datetime] not null DEFAULT (getdate()),
	[Flag] [int] NULL,
	[CreatorID] [int] NULL,
	[CreatorName] [nvarchar](20) NULL,

) 

CREATE TABLE [dbo].[CmsProfile]
(
	[ID] [int] primary key NOT NULL,
	[Name] [nvarchar](100) NULL,
	[Title] [nvarchar](100) NULL,
	[Address] [nvarchar](500) NULL,
	[ZipCode] [varchar](50) NULL,
	[Telephone] [varchar](50) NULL,
	[Mobile] [varchar](50) NULL,
	[Fax] [varchar](50) NULL,
	QQ varchar(100),
	MSN varchar(100),
	[Email] [varchar](100) NULL,
	[Keywords] [nvarchar](1000) NULL,
	[Descriptions] [nvarchar](1000) NULL,
	IPC varchar(100) null,
	IPCount int not null,
	PVCount int not null,
)

create table CmsFreindLink
(
	ID int primary key ,
	[Name] nvarchar(100),
	ImagePath varchar(200),
	Url varchar(200),
)


create table CmsLeaveWord
(
	ID int primary key ,
	[Name] nvarchar(100),
	[Content] nvarchar(max),
	InputTime datetime,
)

create table CmsJob
(
	ID int primary key,
	[Name] nvarchar(50),
	WorkPlace nvarchar(50),
	Salary nvarchar(50),
	Gender int not null,
	Age varchar(50),
	Profession nvarchar(200),
	ContactName nvarchar(50),
	Telephone varchar(50),
	Email varchar(100),
	ExpireDate varchar(50),
	Description nvarchar(1000),
	InputTime datetime not null,
	Orders int not null,
)

create table CmsIP
(
	ID uniqueidentifier primary key,
	IP varchar(50),
	InputTime datetime not null,
)

create table CmsPV
(
	ID uniqueidentifier primary key,
	IP varchar(50),
	Page varchar(200),
	Source varchar(200),
	InputTime datetime not null,
)